import scrapy
from scrapy.http import Request


class ExampleSpider(scrapy.Spider):
    name = 'baidu'
    start_urls = ['http://www.baidu.com/']
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36'
    }

    # def parse(self, response: scrapy.http.Response):
    #     # 打印返回结果
    #     print(response.text)

    def start_requests(self):
        for url in self.start_urls:
            yield Request(url, headers=self.headers, callback=self.my_parse)

    def my_parse(self, response: scrapy.http.Response):
        print("*************" * 5)
        # 打印返回结果
        print(response.text)
        print("*************" * 5)
